package br.com.simulado.util;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

@FacesConverter("br.com.simulador.TextConverter")
public class TextConvert implements Converter {

	@Override
	public Object getAsObject(FacesContext context, UIComponent component, String value) {
		if(value != null){
			return value.getBytes();
		}
		return null;
	}

	@Override
	public String getAsString(FacesContext context, UIComponent componet, Object value) {
		if(value != null && value instanceof byte[]){
			return new String((byte[]) value);
		}
		return null;
	}

}
